using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

using Imagination;
using Imagination.Display;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace ImagineBalls
{
    class PauseScreen : Screen
    {
        ImaginationEngine engine;
        ContentManager content;
        SpriteBatch batch;
        Texture2D pauseTexture;
        Color pauseAlpha;

        public PauseScreen(ImagineBallsGame game) : base(game)
        {
            this.isActive = false;

            this.content = game.Content;
            this.BlocksUpdate = true;
            this.engine = game.Services.GetService(typeof(ImaginationEngine)) as ImaginationEngine;
            Initialize();
        }

        protected override void LoadGraphicsContent(bool loadAllContent)
        {
            if (loadAllContent)
            {
                batch = new SpriteBatch(GraphicsDevice);
                pauseTexture = content.Load<Texture2D>("Content\\Pause");
                pauseAlpha = Color.White;
            }
        }

        public override void Draw(GameTime gameTime)
        {
            Vector2 position = new Vector2(10, GraphicsDevice.Viewport.Height - 240);
            batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);

            batch.Draw(pauseTexture, position, pauseAlpha);
            batch.End();
        }

        public override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)
            {
                isActive = false;
            }

            pauseAlpha = new Color(255, 255, 255, (byte)((DateTime.Now.Second % 2 == 0) ? 127 : 0));
        }

    }
}
